From 625606a7eccffd246b359a12215f1b5bad22b702 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 1 Sep 2020 12:28:17 +0200 Subject: [PATCH] deltas: Add CLI ops to list and reindex delta-indexes --- src/ostree/ot-builtin-static-delta.c | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/ostree/ot-builtin-static-delta.c b/src/ostree/ot-builtin-static-delta.c index 3e0af5bd..ff31b574 100644 --- a/src/ostree/ot-builtin-static-delta.c +++ b/src/ostree/ot-builtin-static-delta.c @@ -53,6 +53,8 @@ BUILTINPROTO(delete); BUILTINPROTO(generate); BUILTINPROTO(apply_offline); BUILTINPROTO(verify); +BUILTINPROTO(indexes); +BUILTINPROTO(reindex); #undef BUILTINPROTO @@ -75,6 +77,12 @@ static OstreeCommand static_delta_subcommands[] = { { "verify", OSTREE_BUILTIN_FLAG_NONE, ot_static_delta_builtin_verify, "Verify static delta signatures" }, + { "indexes", OSTREE_BUILTIN_FLAG_NONE, + ot_static_delta_builtin_indexes, + "List static delta indexes" }, + { "reindex", OSTREE_BUILTIN_FLAG_NONE, + ot_static_delta_builtin_reindex, + "Regenerate static delta indexes" }, { NULL, 0, NULL, NULL } }; @@ -126,6 +134,15 @@ static GOptionEntry verify_options[] = { { NULL } }; +static GOptionEntry indexes_options[] = { + { NULL } +}; + +static GOptionEntry reindex_options[] = { + { "to", 0, 0, G_OPTION_ARG_STRING, &opt_to_rev, "Only update delta index to revision REV", "REV" }, + { NULL } +}; + static void static_delta_usage (char **argv, gboolean is_error) @@ -176,6 +193,46 @@ ot_static_delta_builtin_list (int argc, char **argv, OstreeCommandInvocation *in return TRUE; } +static gboolean +ot_static_delta_builtin_indexes (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) +{ + g_autoptr(OstreeRepo) repo = NULL; + g_autoptr(GOptionContext) context = g_option_context_new (""); + if (!ostree_option_context_parse (context, indexes_options, &argc, &argv, + invocation, &repo, cancellable, error)) + return FALSE; + + g_autoptr(GPtrArray) indexes = NULL; + if (!ostree_repo_list_static_delta_indexes (repo, &indexes, cancellable, error)) + return FALSE; + + if (indexes->len == 0) + g_print ("(No static deltas indexes)\n"); + else + { + for (guint i = 0; i < indexes->len; i++) + g_print ("%s\n", (char*)indexes->pdata[i]); + } + + return TRUE; +} + +static gboolean +ot_static_delta_builtin_reindex (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) +{ + g_autoptr(GOptionContext) context = g_option_context_new (""); + + g_autoptr(OstreeRepo) repo = NULL; + if (!ostree_option_context_parse (context, reindex_options, &argc, &argv, invocation, &repo, cancellable, error)) + return FALSE; + + if (!ostree_repo_static_delta_reindex (repo, 0, opt_to_rev, cancellable, error)) + return FALSE; + + return TRUE; +} + + static gboolean ot_static_delta_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) { -- 2.30.2